package com.zzhardy.example.excelExample;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import cn.zzhardy.utils.poi.ExcelCenter;
import cn.zzhardy.utils.poi.utils.UrlUtils;
import cn.zzhardy.utils.result.AjaxResult;
import com.zzhardy.example.common.SysDept;
import com.zzhardy.example.common.SysLog;
import org.junit.Test;

/**
 * @Author：Hardy
 * @Date：2021/3/27
 * @Function:
 */
public class ExcelExample {
    @Test
    public void createByExcel() {
        List<SysLog> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            SysLog sysLog = new SysLog();
            sysLog.setExceptionInfo("测试");
            sysLog.setJobLogId(i);
            sysLog.setJobMessage("ce111");
            if (i % 2 == 0) {
                sysLog.setStatus(1);
            } else {
                sysLog.setStatus(0);
            }
            sysLog.setCreateDate(new Date());
            String     imageUrl         = UrlUtils.projectUrl() + "webapp/images/timg.jpg";
            sysLog.setErrorImageUrl(imageUrl);
       
            list.add(sysLog);
        }
        ExcelCenter<SysLog> util = new ExcelCenter<>(SysLog.class);
        AjaxResult          form = util.exportExcel(list, "form");
        System.out.println(form.toString());
    }
}
